import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/login/login_btn_widget.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/login/login_code_input.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/login/login_user_input.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/login/tourists_mode_widget.dart';
import 'package:flutter_eve_plugin/constants/constant.dart';
import 'package:flutter_eve_plugin/pages/main/actions.dart';
import 'package:flutter_eve_plugin/pages/ye_xiu/login/actions.dart';
import 'package:flutter_eve_plugin/plugin/main.dart';
import 'package:flutter_eve_plugin/store/main.dart';
import 'package:flutter_eve_plugin/store_vm/app_vm.dart';
import 'package:flutter_eve_plugin/store_vm/ye_xiu/login/main.dart';
import 'package:flutter_eve_plugin/store_vm/ye_xiu/main.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';
import 'package:flutter_redux/flutter_redux.dart';

class LoginMainPage extends StatefulWidget {
  final String title;

  LoginMainPage({Key key, this.title}) : super(key: key);

  @override
  _LoginMainPageState createState() => _LoginMainPageState();
}

class _LoginMainPageState extends State<LoginMainPage> {
  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, AppStateViewModel>(
        onInit: (store) {
          PluginEve.sendMessage(PluginConstant.httpAccountInfo, httpType: HttpType.POST).then((data) {
            store.dispatch(accountInfo(store, context, data));
          });
        },
        converter: (store) => AppStateViewModel(
            state: store.state,
            yeXiuStateViewModel: YeXiuStateViewModel(
                loginStateViewModel: LoginStateViewModel(appDebug: () {
              store.dispatch(appDebug());
            }))),
        builder: (context, vm) {
          return Material(
            color: Color(0xFFFFFFFF),
            child: GestureDetector(
              onTap: () {
                FocusScope.of(context).requestFocus(FocusNode());
              },
              onLongPress: () {
                //这里做10次点击判断
                vm.yeXiuStateViewModel.loginStateViewModel.appDebug();
              },
              child: SingleChildScrollView(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    SizedBox(
                      height: setRatio(70),
                    ),
                    Center(
                      child: Image.asset(
                        imageUtilYeXiu('main/icon_logo@2x'),
                        width: setRatio(128),
                        height: setRatio(128),
                      ),
                    ),
                    SizedBox(
                      height: setRatio(77),
                    ),
                    LoginUserWidget(),
                    SizedBox(
                      height: setRatio(12),
                    ),
                    LoginCodeWidget(),
                    SizedBox(
                      height: setRatio(54),
                    ),
                    LoginBtnWidget(),
                    SizedBox(
                      height: setRatio(26),
                    ),
                    TouristsModeWidget(),
                  ],
                ),
              ),
            ),
          );
        });
  }
}
